<template>
  <div class="formplane">
    <el-form ref="elForm" :model="formdata" size="medium" :rules="rules" label-width="100px">
      <el-form-item label="转办人" prop="ccOperation" label-width="100px">
        <selector :typemode="1" :ismulti="false" :checklisted.sync="checklisted"></selector>
      </el-form-item>
      <el-form-item label="转办原因" prop="commentContent" label-width="100px">
        <el-input type="textarea" :rows="2" placeholder="请输入转办原因" v-model="formdata.commentContent" maxlength="1000">
        </el-input>
      </el-form-item>
      <el-form-item label-width="100px" class="buttonitem">
        <el-button type="primary" @click="confirm">确定</el-button>
        <el-button @click="cancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data () {
    return {
      formdata: { commentContent: '' },
      checklisted: [],
      rules: {
        commentContent: [
          {
            required: true,
            message: '转办原因必填',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  methods: {
    cancel () {
      this.$emit('cancel')
    },
    confirm () {
      this.$refs.elForm.validate(valid => {
        if (!valid) return
        if (this.checklisted === undefined || this.checklisted.length === 0) {
          this.$message.error('转办人不能为空！')
          return
        }
        this.$emit('confirm', {
          redritUser: this.checklisted[0].No,
          approvedDes: this.formdata.commentContent
        })
      })
    }
  }
}
</script>
<style scoped>
.formplane {
  margin: 15px;
}
.buttonitem >>> .el-form-item__content {
  float: right;
  height: 100%;
}
</style>
